package com.leetcodehot.problems;

public class problems2302 {
    public long countSubarrays(int[] nums, long k) {
        //key = sum * (right-left+1)
        int n = nums.length;
        int left = 0;
        long sum = 0L;
        long res = 0L;
        for (int right = 0; right < n; right++) {
            sum += nums[right];
            while (sum * (right - left + 1) >= k) {
                sum -= nums[left++];
            }
            //对于符合条件的情况
            if(left<=right){
                res+= right-left+1;
            }
        }
        return res;
    }
}
